/*******************************************************************************
* CHIPSEA F61 POWER HAL
*******************************************************************************/

#include "hal_cs_f70_power.h"

#ifdef CS_F70

#include "system_control.h"


EM_POWER em_power;

ST_POWER st_power = {
	I2C_START,
	IIC_TIME_OUT,
};


void hal_power_control(void)
{
	switch(st_power.state)
	{
	case ENTER_SLEEP:
		pwr_enter_sleep_mode(DEEP_SLEEP_MODE2,WFI_Mode);

		break;
	case I2C_START:
		st_power.time_out_count = IIC_TIME_OUT;
		st_power.state = I2C_WORKING;

		break;
	case I2C_WORKING:
		pwr_enter_sleep_mode(NORMAL_SLEEP_MODE,WFI_Mode);
		st_power.time_out_count -= st_sys_ctr.period;

		if(st_power.time_out_count <= 0)
		{
			st_power.state = ENTER_SLEEP;
		}
		
		break;
	default:
		break;
	}

}

//////////////////////////////////////////////////////////////////////////////////////////

#endif /* End of CS_F61 */
